﻿@{
    ViewBag.Title = "Services";
}

<div ng-app="app" ng-controller="serviceCtrl">
    <div class="row">
        <div class="col-md-12">
            Gehalt: <input type="text" class="form-control" is-number ng-model="ModelData.Gehalt" /> <br/>
            <br/>
            Formatiertes Gehalt: <label ng-bind="ModelData.Gehalt + ' Währung'"></label>

        </div>
        <div class="col-md-12">
            <hr/>
        </div>
        <div class="col-md-12">Geburtstag: <input type="text" class="form-control" ng-model="ModelData.Geburtstag" /></div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <br/>
            <input type="button" class="btn btn-default" ng-click="Fct.Save()" value="Speichern" />
        </div>
    </div>
</div>

@section scripts
{
    <script type="text/javascript" src="~/ScriptsAngular/directives/numberDirectives.js"></script>

    <script>
        var app = angular.module("app", ["app.numberDirectives"]);

       

        app.service("serviceSrv", function ($log, $http) {
                this.GetModelData = function () {
                    return $http.get('/Home/GetModelData').then(function (result) {
                        return result.data;
                    });
                }
                this.SaveModelData = function (model) {
                    return $http.post('/Home/SaveModelData', model).then(function (result) {
                        return result.data;
                    });
                }
            });

        app.controller("serviceCtrl", function ($scope, $log, serviceSrv) {
               $scope.Fct = {};

               serviceSrv.GetModelData().then(function (data) {
                   $scope.ModelData = data;
               });

               $scope.Fct.Save = function () {
                   serviceSrv.SaveModelData($scope.ModelData).then(function (data) {
                       $scope.ModelData = data;
                   });
               }
           });

    </script>
}

